<template>
	<view>
		<view class="u-flex user-box u-p-t-30 u-p-l-30 u-p-r-20 u-p-b-30" :class="{avatarBody: isAndroid}">
			<view class="u-m-r-10 avatar-body">
				<oss-upload></oss-upload>
			</view>
			<view class="u-flex-1" :class="{nameBody: isAndroid}">
				<view class="u-font-18 u-p-b-20">{{vuex_user.name}}</view>
				<view class="u-font-14 u-tips-color">邮箱:{{vuex_user.email}}</view>
			</view>
			
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="setting" title="个人信息" @click="toBaseInfo"></u-cell-item>
			</u-cell-group>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="order" title="订单"></u-cell-item>
				<u-cell-item icon="star" title="收藏"></u-cell-item>
				<u-cell-item icon="coupon" title="卡券"></u-cell-item>
				<u-cell-item icon="map" title="地址"></u-cell-item>
			</u-cell-group>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="close-circle" title="退出" @click="logout"></u-cell-item>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pic:'https://uviewui.com/common/logo.png',
				show:true
			}
		},
		onLoad() {
			if(!this.$u.utils.isLogin()) return
			console.log(this.$u.utils.isAndroid());
		},
		methods: {
			toBaseInfo(){
				this.$u.route({
					url:'pages/center/baseInfo'
				})
			},
			//退出登录
			async logout(){
				//请求api，退出登录
				await this.$u.api.authLogout()
				this.$u.toast('退出登录成功')
				setTimeout(()=>{
					this.$u.vuex('vuex_token',null)
					this.$u.vuex('vuex_user',{})
					
					//跳转首页
					this.$u.route({
						type:'reLaunch',
						url:'pages/index/index'
					})
				},1500)
				//清除缓存，用户信息
			}
		}
	}
</script>

<style lang="scss">
page{
	background-color: #ededed;
}

.camera{
	width: 54px;
	height: 44px;
	
	&:active{
		background-color: #ededed;
	}
}
.avatar-body{
	height: 70px;
	width: 70px;
}
.user-box{
	background-color: #fff;
}
.avatarBody{
	padding: 50rpx 30rpx !important;
}
.nameBody {
	margin-left: 40rpx;
	margin-top: 30rpx;
}

</style>

